<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4ecf5 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .register-container {
            background-color: white;
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 900px;
            display: flex;
            overflow: hidden;
            animation: fadeIn 0.6s ease-out;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .left-panel {
            flex: 1;
            background: linear-gradient(135deg, #165DFF 0%, #0047CC 100%);
            color: white;
            padding: 60px 40px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }

        .left-panel::before {
            content: '';
            position: absolute;
            top: -50px;
            right: -50px;
            width: 200px;
            height: 200px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 50%;
        }

        .left-panel::after {
            content: '';
            position: absolute;
            bottom: -80px;
            left: -80px;
            width: 300px;
            height: 300px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 50%;
        }

        .panel-content {
            position: relative;
            z-index: 1;
        }

        .left-panel h2 {
            font-size: 32px;
            margin-bottom: 20px;
            font-weight: 600;
        }

        .left-panel p {
            font-size: 16px;
            line-height: 1.6;
            margin-bottom: 40px;
            opacity: 0.9;
        }

        .benefits-list {
            list-style: none;
        }

        .benefits-list li {
            margin-bottom: 15px;
            display: flex;
            align-items: center;
        }

        .benefits-list li i {
            margin-right: 12px;
            font-size: 20px;
            color: #8BC34A;
        }

        .right-panel {
            flex: 1;
            padding: 60px 50px;
        }

        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 40px;
            font-size: 28px;
            font-weight: 600;
            position: relative;
        }

        h1::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 60px;
            height: 3px;
            background: #165DFF;
            border-radius: 3px;
        }

        .form-group {
            margin-bottom: 25px;
            position: relative;
        }

        .form-group i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #999;
            font-size: 18px;
        }

        .form-group input,
        .form-group select {
            width: 100%;
            padding: 14px 15px 14px 45px;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            font-size: 16px;
            transition: all 0.3s ease;
            background-color: white;
        }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: #165DFF;
            box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #555;
            font-size: 15px;
        }

        .password-strength {
            height: 5px;
            margin-top: 8px;
            display: flex;
            gap: 3px;
        }

        .strength-bar {
            flex: 1;
            border-radius: 3px;
            background-color: #e0e0e0;
            transition: all 0.3s ease;
        }

        .btn-primary {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, #165DFF 0%, #0047CC 100%);
            color: white;
            font-size: 16px;
            font-weight: 500;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(22, 93, 255, 0.2);
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #0047CC 0%, #003AB3 100%);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(22, 93, 255, 0.3);
        }

        .error {
            color: #FF4D4F;
            text-align: center;
            margin-bottom: 20px;
            padding: 10px;
            background: rgba(255, 77, 79, 0.05);
            border-radius: 6px;
            border-left: 3px solid #FF4D4F;
            font-size: 14px;
            font-weight: 500;
            opacity: 0;
            transform: translateY(-10px);
            animation: fadeInError 0.5s ease-out forwards;
        }

        @keyframes fadeInError {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .login-link {
            text-align: center;
            margin-top: 25px;
            font-size: 14px;
            color: #666;
        }

        .login-link a {
            color: #165DFF;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .login-link a:hover {
            color: #0047CC;
            text-decoration: underline;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .register-container {
                flex-direction: column;
            }

            .left-panel, .right-panel {
                flex: none;
            }

            .left-panel {
                padding: 40px 30px;
            }

            .right-panel {
                padding: 40px 30px;
            }
        }
    </style>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div class="register-container">
    <!-- 左侧介绍区域 -->
    <div class="left-panel">
        <div class="panel-content">
            <h2>欢迎加入应急响应系统</h2>
            <p>注册成为我们的一员，共同构建安全社区</p>

            <ul class="benefits-list">
                <li><i class="fa fa-check-circle"></i> 及时获取紧急通知</li>
                <li><i class="fa fa-map-marker"></i> 快速上报灾情信息</li>
                <li><i class="fa fa-users"></i> 与应急团队实时协作</li>
                <li><i class="fa fa-shield"></i> 提高社区安全保障</li>
            </ul>
        </div>
    </div>

    <!-- 右侧表单区域 -->
    <div class="right-panel">
        <h1>创建账户</h1>

        <% if (request.getAttribute("error") != null) { %>
        <div class="error"><%= request.getAttribute("error") %></div>
        <% } %>

        <form action="regservlet" method="post">
            <div class="form-group">
                <i class="fa fa-user"></i>
                <label for="username">用户名</label>
                <input type="text" id="username" name="username" required placeholder="请输入用户名">
            </div>

            <div class="form-group">
                <i class="fa fa-lock"></i>
                <label for="password">密码</label>
                <input type="password" id="password" name="password" required minlength="6" placeholder="请输入密码">
                <div class="password-strength">
                    <div class="strength-bar" id="strength-1"></div>
                    <div class="strength-bar" id="strength-2"></div>
                    <div class="strength-bar" id="strength-3"></div>
                    <div class="strength-bar" id="strength-4"></div>
                </div>
            </div>

            <div class="form-group">
                <i class="fa fa-envelope"></i>
                <label for="email">电子邮箱</label>
                <input type="email" id="email" name="email" placeholder="请输入电子邮箱（选填）">
            </div>

            <div class="form-group">
                <i class="fa fa-user-circle"></i>
                <label for="role">角色</label>
                <select id="role" name="role" required>
                    <option value="">请选择角色</option>
                    <option value="resident">普通居民</option>
                    <option value="emergency">应急人员</option>
                </select>
            </div>

            <button type="submit" class="btn-primary">立即注册</button>
        </form>

        <div class="login-link">
            已有账号？<a href="index.jsp">立即登录</a>
        </div>
    </div>
</div>

<script>
    // 密码强度检测
    document.getElementById('password').addEventListener('input', function() {
        const password = this.value;
        const strengthBars = document.querySelectorAll('.strength-bar');
        let strength = 0;

        // 密码长度检测
        if (password.length >= 6) strength++;
        if (password.length >= 10) strength++;

        // 密码复杂度检测
        if (/[A-Z]/.test(password)) strength++;
        if (/[0-9]/.test(password)) strength++;
        if (/[^A-Za-z0-9]/.test(password)) strength++;

        // 更新强度条
        strengthBars.forEach((bar, index) => {
            if (index < strength) {
                bar.style.backgroundColor = '#165DFF';
            } else {
                bar.style.backgroundColor = '#e0e0e0';
            }
        });
    });
</script>
</body>
</html>